package com.paziy.jan.calc.literals.operations;

import com.paziy.jan.calc.literals.numbers.Num;
import com.paziy.jan.calc.literals.operations.associations.*;
import java.util.*;

public class Sum extends Operation {

    private static final String PATTERN = "\\+";

    private static final byte COUNT_OF_OPERANDS = (byte)2;

    private static final byte PRIORITY = (byte)10;

    private static final Association ASSOCIATION = AssociatedFull.getInstance();

    public Sum() {
        super(PATTERN, COUNT_OF_OPERANDS, PRIORITY, ASSOCIATION);
    }

    @Override
    protected Num calculating(LinkedList<Num> stack) {
        return new Num(stack.pop().bigDecimalValue().add(stack.pop().bigDecimalValue()));
    }
}
